home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / rs0422.zip / LEVEL1 / HANDIPKT.AS < prev    next >
Text File  |  1990-09-25  |  10KB  |  312 lines

  1. ;/*
  2. ; * Copyright 1988 by the Radio Amateur Telecommunications Society
  3. ; * and Thomas A. Moulton, W2VY
  4. ; *
  5. ; * This software may only be modified, copied, distributed or
  6. ; * executed for non-profit purposes by individuals operating
  7. ; * systems in the Amateur Radio Service.  Credit to the
  8. ; * author(s) and to the Radio Amateur Telecommunications Society
  9. ; * must be made in modules where RATS provided software is used,
  10. ; * and in any announcements and documentation.  
  11. ; *
  12. ; * As a non-profit, research and development organization,  the
  13. ; * Radio Amateur Telecommunications Society distributes software
  14. ; * in both executable and source forms.  This policy is in place
  15. ; * to encourage the development and distribution of OSI-based,
  16. ; * networking tools.  In order to protect the interests of the
  17. ; * Society and the authors, we have placed some conditions
  18. ; * of use on the software.  Other groups are encouraged
  19. ; * to place the same or similar guidelines on
  20. ; * software they produce.
  21. ; *
  22. ; * The Radio Amateur Telecommunications Society reserves the right
  23. ; * to specify and alter the terms under which software provided by
  24. ; * the Society may be used.  This policy is consistent with the 
  25. ; * objective of uniform and consistent "Open Systems Interconnections."
  26. ; * 
  27. ; * All acceptable Amateur Radio related uses of this software
  28. ; * will be outlined in the "ROSE Implementer's Guide".  Individuals
  29. ; * or organizations wishing to add to, or modify the provisions of
  30. ; * the guide to accommodate local or evolutionary requirements
  31. ; * should document the proposed change(s) and forward them to the
  32. ; * Society.  If accepted, written notification will be provided by
  33. ; * the Society to the submitting organization or individual(s).
  34. ; * The Society will then issue a "ROSE Implementer's Guide Change
  35. ; * Notice".  Periodically, the Society will re-issue the "ROSE 
  36. ; * Implementer's Guide" and incorporate the text of the change 
  37. ; * notices.  This procedure has been put in to place to ensure
  38. ; * compatibility between systems and to ensure their "Openness"
  39. ; * and interoperability.
  40. ; *
  41. ; * No part of this software may be used in other packages 
  42. ; * without prior authorization from the author or the Society.  
  43. ; * Software incorporating this module, all or in part, must be 
  44. ; * provided to the Society prior to distribution or use by
  45. ; * anyone not directly involved in testing of the revised  
  46. ; * environment.  Current releases of the combined software must
  47. ; * be provided to the Society in both source and executable
  48. ; * forms.  Adequate documention to produce an executable module 
  49. ; * from the provided source must also be included.
  50. ; *
  51. ; * Non-Amateur Radio non-profit uses may be authorized on a case
  52. ; * by case basis.  Inquiries for such use may be made in writing
  53. ; * to the Society. Non-commercial uses consistent with the
  54. ; * general principles of Open Systems Interconnection Reference
  55. ; * Model will be generally considered with favor.
  56. ; *
  57. ; * Commercial licensing of the software is also available based
  58. ; * on normal commercial terms.  Licensing inquiries should be
  59. ; * directed to the Society.  Commercial licensing of the standard
  60. ; * software will be done in situations which materially benefit
  61. ; * the Amateur Radio Packet Network.  Additional licensing is
  62. ; * reserved by the individual authors.
  63. ; * 
  64. ; * The Radio Amateur Telecommunications Society provides this software
  65. ; * on an "as is" basis.  The Society assumes no liability for
  66. ; * loss incurred through the use of this software.  Amateur Radio
  67. ; * use of this software implies non-commercial and voluntary 
  68. ; * development, deployment and use of this software in a "Amateur",
  69. ; * non-commercial service.  Commercial users are encouraged to
  70. ; * inspect their copies of the source code.  Source code modification
  71. ; * licenses are available if a combined Object and Source Code
  72. ; * license was not originally established.
  73. ; * 
  74. ; * The Society may be contacted by writing or calling at:
  75. ; * 
  76. ; * The Radio Amateur Telecommunications Society 
  77. ; * 206 North Vivyen Street.
  78. ; * Bergenfield, New Jersey 07621
  79. ; *
  80. ; * Telephone: 201-387-8896
  81. ; *
  82. ; */
  83. ;
  84. ; System Init for ROM
  85. ;
  86.     psect    text,pure
  87.  
  88. *INCLUDE RCONFIG.LIB
  89. *INCLUDE STRUCT.LIB
  90.  
  91. MSYNC    EQU    10H
  92. CTS    EQU    5        ;SIO RR0 CTS Bit (Mask 20h)
  93. POWER_FAIL EQU    0150H
  94.  
  95.     GLOBAL    CLKBIT, TICKCNT, HDWbss
  96.  
  97.     psect    text
  98. start:    di            ;Insure NO int's!!
  99.     jp    POWER_FAIL    ;Power Failure, check memory, etc
  100.     jp    INIT_HDW    ;Set up SDS's based on the machine type
  101.     jp    INIT_LED    ;Init Led's
  102.     jp    UPD_LED        ;Change Led's (toggle)
  103.     jp    halted        ;We are halted...
  104.  
  105.     global    amul, brelop, wrelop, csv, cret
  106.  
  107. RST2:    jp    (hl)        ;for optimizer    **********'0010'**************
  108.     defm    'PacComm'
  109. RST3:    jp    amul        ;for optimizer    **********'0018'**************
  110.     defm    'TNC -'
  111. RST4:    jp    brelop        ;for optimizer    **********'0020'**************
  112.     defm    '320HF'
  113. RST5:    jp    wrelop        ;for optimizer    **********'0028'**************
  114.     defm    'W2VY'
  115.     defb    0
  116. RST6:    jp    csv        ;for optimizer    **********'0030'**************
  117.     defm    'ROSE'
  118.     defb    0
  119. RST7:    ex    (sp),hl        ;for optimizer    **********'0038'**************
  120.     pop    hl
  121.     jp    cret
  122.  
  123. tickcnt: defb    3        ;Clock is at 150 hz (IT IS RF Speed/8)
  124.     defw    TBAUD+1        ;Pointer to Terminal baud rate
  125.     defw    RBAUD+1        ;Pointer to Radio baud rate byte (SCCBI)
  126. ileds:    defb    0        ;Initial LED Pattern
  127.     defw    SDSI0, SDSI1
  128.  
  129.     global    SDS0, SDS1
  130.  
  131. ;  Initialize the SCC data structures
  132.  
  133. INIT_HDW:
  134.     LD    HL,SDSI0    ;Copy from ROM
  135.     LD    DE,SDS0        ;To RAM
  136.     LD    BC,SDSILEN
  137.     LDIR
  138.  
  139.     LD    HL,SDSI1    ;Copy from ROM
  140.     LD    DE,SDS1        ;To RAM
  141.     LD    BC,SDSILEN
  142.     LDIR
  143.  
  144.     LD    A,09
  145.     LD    C,00
  146.     OUT    (C),A        ;WR 9
  147.     LD    A,0C0H        ;Master Reset for SCC
  148.     OUT    (C),A
  149.  
  150.     LD    A,MSYNC        ;HandiPacket Clock bit (SYNCB)
  151.     LD    (CLKBIT),A    ;Save it
  152.     LD    A,(tickcnt)
  153.     LD    (TICKCNT),A    ;Number of Interrupts/Tick to 10ms
  154.  
  155. ;    Is the async port on a back-to-back cable?
  156.  
  157.     LD    IY,SDS1        ;Async Port
  158.     LD    C,(IY+CPORT)    ;Port Address
  159.     IN    A,(C)        ;Get RR0 Status
  160.     BIT    CTS,A        ;CTS ON?
  161.     RET    NZ        ;No, leave TXDelay Alone
  162.     XOR    A
  163.     LD    (IY+TXDLY),A    ;Yes, Set TXDelay=0 for Async Port
  164.     LD    (IY+(TXDLY+1)),A
  165.     RET
  166.  
  167. INIT_LED:        ;Enter with (_COLD) in A and B
  168.     LD    D,5
  169.     LD    IY,SDS0        ;Get address of port 0
  170.     LD    C,(IY+CPORT)    ;STA Led
  171.     OUT    (C),D        ;WR 5
  172.     LD    A,B
  173.     AND    40h        ;STA Led is second bit
  174.     SLA    A
  175.     LD    E,A
  176.     LD    A,(IY+WR5REG)    ;Get Current value
  177.     AND    7Fh        ;Ignore DTR
  178.     OR    E        ;Set DTR
  179.     OUT    (C),A
  180.     LD    IY,SDS1        ;Get to SDS1
  181.     LD    C,(IY+CPORT)    ;CON Led
  182.     OUT    (C),D        ;WR 5
  183.     LD    A,B
  184.     AND    80h        ;CON Led is High Bit
  185.     LD    E,A
  186.     LD    A,(IY+WR5REG)
  187.     AND    7Fh        ;Ignore DTR
  188.     OR    E        ;Set DTR
  189.     OUT    (C),A        ;LEDS Now indicate Restart Cause
  190.     RET
  191.  
  192. UPD_LED:
  193.     call    csv
  194.     ld    hl,SDS0            ;Get to SDS0
  195.     call    toggle
  196.     ld    hl,SDS1            ;Get to SDS1
  197.     call    toggle
  198.     jp    cret
  199.  
  200. toggle:
  201.     ld    de,CPORT
  202.     add    hl,de
  203.     ld    c,(hl)        ;Get command port address
  204.     ld    de,WR5REG-CPORT
  205.     add    hl,de
  206.     ld    b,5        ;WR 5
  207.     DI
  208.     ld    a,(hl)
  209.     xor    80h
  210.     ld    (hl),a
  211.     out    (c),b
  212.     out    (c),a
  213.     EI
  214.     ret
  215.  
  216. halted:    LD    C,0    ;Turn PMS Led ON
  217.     LD    A,50h
  218.     OUT    (C),A
  219.     HALT
  220.     LD    A,54h    ;Turn PMS Led OFF
  221.     OUT    (C),A
  222.     RET
  223.  
  224.     GLOBAL    SDSI0, SDSI1
  225. SDSI0:    DEFB    0        ;Channel number
  226.     DEFB    3        ;SCC data port
  227.     DEFB    1        ;SCC control port
  228.     DEFW    DWAIT0
  229.     DEFW    TXDELAY0
  230.     DEFW    SCCAI        ;SYNC CONFIG
  231.     DEFB    SCCAIL        ;LEN
  232.     DEFB    0        ;Flags
  233.     DEFB    069h        ;WR5REG (DTR Off)
  234.  
  235. SDSI1:    DEFB    1        ;Channel number
  236.     DEFB    2        ;SIO data port
  237.     DEFB    0        ;SIO control port
  238.     DEFW    DWAIT1
  239.     DEFW    TXDELAY1
  240.     DEFW    SCCBI        ;8530 Async Config
  241.     DEFB    SCCBIL        ;LEN
  242.     DEFB    MASYNC+MTIMER+MAFT ;Line for timer
  243.     DEFB    0E8h        ;WR5REG DTR is Now ON, RTS Off
  244.     ENDC
  245.  
  246. ;  Fixed data
  247.  
  248. ;  SCC SYNC initialization block.
  249.  
  250. SCCAI:    DEFB    4,0A0H        ;X32, SDLC, Sync
  251.     DEFB    10,0A0H        ;Init CRC, NRZI
  252.     DEFB    7,7EH        ;Sync Definitition (No S!!t)
  253.     DEFB    2,0H        ;Interrupt Vector
  254.     DEFB    3,0DAH        ;8 bit Rx, Enter Hunt, RXCRC, Sync Load Inh.
  255.     DEFB    5,68H        ;8 Bit Tx, Tx Enable
  256. ; next 3 lines are for internal baud rate with external divider for TXC
  257.     DEFB    11,66H    ;RXC=DPLL O/P, TXC=RTxC, TRxC=O, TRxC Out=BRG Out
  258. RBAUD:    DEFB    12,62,13,0    ;Time Constant (1200 Baud) (PCLK/(2*32*baud))-2
  259. ;    300 baud = 254, 600 baud = 126, 1200 baud = 62, 9600 baud = 6
  260.     DEFB    14,82H        ;Set Source=BRG, BR Generator source
  261. ; next 2 lines are for external clocks
  262. ;    DEFB    11,68H        ;RXC = DPLL Out, TXC = TRxC, TRxC=IN,
  263. ;    DEFB    14,0A0H        ;DPLL Source = RTxC (x32 clock)
  264.     DEFB    5,0E9H        ;DTR On (Port 1),8 bitTx,TxEnable,TX CRC Enable
  265.     DEFB    3,0DBH        ;Same as 3 above, RX Enable
  266.     DEFB    14,23H        ;Enter Search Mode, Enable BRG
  267.     DEFB    15,0E8H        ;Enable Interrupts on 
  268.     DEFB    10H,10H        ;Reset External Interupts, Twice
  269.     DEFB    1,13H        ;Interrupt on Receive and Xmit
  270. SCCAIL    EQU     $-SCCAI
  271.  
  272. ;  SCC ASYNC initialization block.
  273.  
  274. SCCBI:
  275. TBAUD:    DEFB    12,14,13,0    ;Time Constant (9600 Baud) (PCLK/(2*16*baud))-2
  276. ;    1200 baud = 126, 2400 = 62, 4800 = 30, 9600 = 14
  277.     DEFB    5,0E8H        ;WR5, DTR On + 8bit + TxEnable + RTS Off
  278.     DEFB    3,0C1H        ;WR3, 8bit + RxEnable
  279.     DEFB    4,044H        ;WR4, 16xClk + 1Stop + NoParity
  280. ; Internal baud rate generator
  281.     DEFB    11,54H        ;RXC = BRG, TXC = BRG, TRXC OUT, TRXC=BRG
  282.     DEFB    14,02H        ;BRG Source
  283.     DEFB    14,03H        ;BRG Source, BRG Enable
  284. ; External Clocking
  285. ;    DEFB    11,00H        ;TXC, RXC - RTxC Pin
  286.     DEFB    15,0F8H        ;Enable Interrupts on
  287.     DEFB    28H,10H,10H    ;Reset TXint, Reset External Ints
  288.     DEFB    1,13H         ;Enable rx, tx, ext ints
  289.     DEFB    9,9        ;Master Interrupt Enable, Vector Includes Stat
  290. SCCBIL    EQU    $-SCCBI
  291.  
  292.     cond    0
  293.  
  294. SCCBI:    DEFB    14h        ;WR 4 + Reset Ext Intr
  295.     DEFB    44H        ;16xClk + 1Stop + NoParity
  296.     DEFB    3,0C1H        ;WR3, 8bit + RxEnable
  297.     DEFB    5,0E8H        ;WR5, DTR On + 8bit + TxEnable + RTS Off
  298. ; Internal baud rate generator
  299.     DEFB    11,54H        ;RXC = BRG, TXC = BRG, TRXC OUT, TRXC=BRG
  300. TBAUD:    DEFB    12,14,13,0    ;Time Constant (9600 Baud) (PCLK/(2*16*baud))-2
  301. ;    1200 baud = 126, 2400 = 62, 4800 = 30, 9600 = 14
  302.     DEFB    14,63H        ;Disable PLL, BRG Source, BRG Enable
  303. ; External Clocking
  304. ;    DEFB    11,00H        ;TXC, RXC - RTxC Pin
  305.     DEFB    15,0F8H        ;Enable Interrupts on
  306.     DEFB    10H,10H        ;Reset External Ints
  307.     DEFB    1,13H         ;Enable rx, tx, ext ints
  308.     DEFB    9,9        ;Master Interrupt Enable, Vector Includes Stat
  309. SCCBIL    EQU    $-SCCBI
  310.  
  311.     endc
  312.